package com.ec.api.enumeration;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.ec.common.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import static com.ec.common.enumeration.BusinessExceptionEnum.PARAM_ERROR;

@Getter
@AllArgsConstructor
public enum EmergencyLevel {
    URGENT("紧急"),
    WARNING("警告"),
    ALERT("预警");

    @EnumValue
    @JsonValue
    private final String value;

    public static EmergencyLevel fromValue(String value) {
        for (EmergencyLevel level : EmergencyLevel.values()) {
            if (level.getValue().equals(value)) {
                return level;
            }
        }
        throw new BusinessException(PARAM_ERROR);
    }
}
